$('.data-header-return').click(function (e) {
    window.history.back(-1);
    e.prevent();
})

$('#demo').mobiscroll().calendar({
    theme: 'mobiscroll',
    lang: 'zh',
    display: 'inline',
})

window.onresize = function () {
    $('#demo').mobiscroll().calendar({
        theme: 'mobiscroll',
        lang: 'zh',
        display: 'inline',
    });
}

touch.config = {
    tap: true,
    doubleTap: true,
    hold: true,
    holdTime: 750,
    swipe: true,
    swipeTime: 300,
    swipeMinDistance: 18,
    swipeFactor: 5,
    drag: true,
    pinch: true,
}

var flag = true;
var personNum = $('.personNum').text();
var childNum = $('.childNum').text();
var num;
var totalPrice;

var flag = true;

touch.on('#demo', 'tap', function () {
    if (flag) {
        flag = false;
        console.log('添加');
        // console.log(flag);
        num = parseInt(Math.random() * 3000 + 1000);
        var htmlstr = '<p style="font-size:0.12rem;margin-top:-10px;color:#1AB2DB">￥' + num + '<p>';
        $('div[aria-selected="true"]').find('.mbsc-cal-day-fg').append(htmlstr);
        $('.manPrice').html('￥' + num + '/人');
        $('.childPrice').html('￥' + num / 2 + '/人');
    } else {
        flag = true;
        console.log('删除');
        // console.log(flag);
        $('div[aria-selected="true"]').find('.mbsc-cal-day-fg p').remove();
    }
})



// touch.on('#demo', 'doubletap', function () {
//     // console.log('删除')
//     $('div[aria-selected="true"]').find('.mbsc-cal-day-fg p').remove();

// })


function addNum(person, child) {
    totalPrice = num * person + num / 2 * child;
    $('.total').text('￥' + totalPrice);
}

$('.add').click(function () {
    personNum++;
    $('.personNum').text(personNum);
    addNum(personNum, childNum);

})


$('.reduce').click(function () {
    personNum--;
    if (personNum < 0) personNum = 0;
    $('.personNum').text(personNum);
    addNum(personNum, childNum);
})

$('.add2').click(function () {
    childNum++;
    $('.childNum').text(childNum);
    addNum(personNum, childNum);
})

$('.reduce2').click(function () {
    childNum--;
    if (childNum < 0) childNum = 0;
    $('.childNum').text(childNum);
    addNum(personNum, childNum);
})
